1 using System;
2 using
System.Collections.Generic;
3 using
System.ComponentModel;
4 using
System.Data;
5 using
System.Data.SqlClient;
6 using
System.Drawing;
7 using
System.Text;
8 using
System.Windows.Forms;
9 using
Telerik.WinControls;
10 using
System.Diagnostics;
11 using
System.ServiceProcess;
12 using
QuanLyNhanSu.Class;
13 namespace
QuanLyNhanSu
14 {
15     
public partial class frmDangNhap : Form
16     {
17         QuanLyNhanSu.Class.readFile c =
new QuanLyNhanSu.Class.readFile();
18         QuanLyNhanSu.Class.sql sql =
new sql();
19         
public frmDangNhap()
20         {
21             InitializeComponent();
22         }
23
24         
private void btnDangNhap_Click(object sender, EventArgs e)
25         {
26
27             
if (txtUserName.Text == "")
28             {
29
30                 RadMessageBox.Show(
"\nTên đăng nhập không được bỏ trống !\n", "Thông Báo", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
31                 txtUserName.Focus();
32
33
34             }
35             
else
36             {
37                 
if (txtPassword.Text == "")
38                 {
39                     RadMessageBox.Show(
"\nMật khẩu không được bỏ trống !\n", "Thông Báo", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
40                     txtUserName.Focus();
41
42                 }
43                 
else
44                 {
45                     
string u = txtUserName.Text.Trim();
46                     
string p = txtPassword.Text.Trim();
47                     SqlConnection con = sql.connectSQL();
48                     con.Open();
49                     SqlCommand scmd =
new SqlCommand(
50                     
"select ID,pass from tbl_user where " +
51                     
" ID = '" + u + "' and " +
52                     
" pass = '" + p + "' ", con);
53                     SqlDataReader sdr =
54                         scmd.ExecuteReader();
55
56
57                     
if (sdr.Read())
58                     {
59                         
string strServerName = "";
60                         
string strDatabase = "";
61                         
string strUserName = "";
62                         
string strPassword = "";
63
64                         
string dbu = sdr.GetString(0).Trim();
65                         
string dbp = sdr.GetString(1).Trim();
66
67                         sdr.Close();
68                         con.Close();
69                         c.readfile();
70
71                         
if (c.strLine1.Contains("Server:") == true) strServerName = c.strLine1.Substring(7);
72                         
if (c.strLine2.Contains("Database:") == true) strDatabase = c.strLine2.Substring(9);
73                         
if (c.strLine3.Contains("Username:") == true) strUserName = c.strLine3.Substring(9);
74                         
if (c.strLine4.Contains("Password:") == true) strPassword = c.strLine4.Substring(9);
75
76                         frmMain.me.sql =
77                             
new sql(strServerName, strDatabase, dbu, dbp);
78
79                         
if (dbu != "administrator")
80                         {
81                             frmMain.me.btnPhanQuyen.Enabled =
false;
82                             frmMain.me.btnTaoNguoiDung.Enabled =
false;
83                             
//MessageBox.Show(dbu+" "+dbp);
84                         }
85                         
else
86                         {
87                             
//MessageBox.Show(dbu + " " + dbp);
88                             frmMain.me.btnPhanQuyen.Enabled =
true;
89                             frmMain.me.btnTaoNguoiDung.Enabled =
true;
90                         }
91                         frmMain.me.lbNguoiDung.Text =
"Người đăng nhập :" + u;
92                         frmMain.me.lbTrangThai.Text =
"Trạng Thái : Sẳn Sàng";
93                         frmMain.me.lbTrangThai.Image =
null;
94                         
this.Close();
95
96                     }
97                     
else
98                     {
99                         sdr.Close();
100                         con.Close();
101                         RadMessageBox.Show(
"\nBạn Chưa đăng ký hoặc mật mã không đúng !\n", "Thông báo",MessageBoxButtons.OK,RadMessageIcon.Exclamation);
102
103                     }
104                 }
105
106
107             }
108            
109             
110         }
111
112         
private void btnExit_Click(object sender, EventArgs e)
113         {
114             Application.Exit();
115
116            
117
118         }
119         
public int a;
120         
public bool b = false;
121        
122         
private void button1_Click(object sender, EventArgs e)
123         {
124             
//System.Diagnostics.Process.Start("osk");
125             
if (b == false)
126             {
127                 
128                 a = System.Diagnostics.Process.Start(
"osk").Id;
129                 
this.txtPassword.Text = "";
130                 b =
true;
131                 
this.txtPassword.Focus();
132             }
133             
else
134             {
135                 System.Diagnostics.Process.GetProcessById(a).Kill();
136                 b =
false;
137             }
138          
139           
140
141         }
142
143         
private void frmDangNhap_FormClosed(object sender, FormClosedEventArgs e)
144         {
145             
if (b == true && a !=null)
146             {
147                 System.Diagnostics.Process.GetProcessById(a).Kill();
148                 b =
false;
149             }
150             
151         }
152
153      
154
155       
156
157
158
159        
160
161        
162
163       
164
165         
166
167         
168     }
169 }



Quản lý nhân sự công ty bằng c# _ full source code 60.411 lượt xem

Gõ tìm kiếm nhanh...